package intermouse;

import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * A tĂłcsa osztĂˇly
 * 
 * @author SĹ‘re AndrĂˇs
 * @author Greff Balázs 
 * @version 1.0
 * @since 2013-03-24
 */
public class Water extends FieldObject {
	Water(){
		super();
		fieldType = FieldTypes.Water;
	}
	
	/**
	 * a tĂłcsa kiterjedĂ©se tĂ¶bb szomszĂ©dos mezĹ‘re
	 * 
	 * @param fields
	 *            a vele szomszdos mezĹ‘k
	 */
	
	void spreadWater(int fields) { //fields: 0,1,2 lehet; ez a sugĂˇr
		Logger.printToConsole(">> Water.spreadWater() : void");
		
		if(fields>2)
		{	
			fields=2;
		}
		
		if(fields>0&&fields<=2)
		{
			int vege=0;//nem terjed mĂˇr ha vege=fields

			List<Field> adj;//kiindulĂł mezĹ‘ szomijai
			adj=field.getAdjacentFields();

			//boolean bejarva=false;
			//Map<Field,boolean> tomb=new Hashmap<Field,boolean>();
			//tomb.put(this.field,true);

			Iterator<Field> iterator=adj.iterator();
			while(iterator.hasNext())
			{
				//tomb.put(iterator.next(),true);
				Water w = new Water();
				w.setField(iterator.next());
				//iterator.next().addFieldObject(new Water());
			}
			vege++;

			Iterator<Field> iterator2=adj.iterator();
			//List<Field> adjadj;
			while(vege!=fields)
			{
				while(iterator2.hasNext())
				{
					List<Field> temp=iterator2.next().getAdjacentFields();
					Iterator<Field> tempiterator=temp.iterator();
					while(tempiterator.hasNext())
					{
						//adjadj.add(tempiterator.next());
						//tomb.put(tempiterator.next(),true);
						//if(tomb.)
						Water w = new Water();
						w.setField(tempiterator.next());
						//tempiterator.next().addFieldObject(new Water());
					}
				}
				vege++;
			}
		}
		
		Logger.printToConsole("<< return");
	}
	
	boolean canStep(Ant ant) {
		Logger.printToConsole(">> Water.canStep(Ant) : bool");
		Logger.printToConsole("<< return");
		return false;
	}
}
